<?php

namespace app\shop\model\recharge;

use app\shop\model\BaseModel;
use app\shop\model\PaymentTradeModel;
use app\shop\model\user\UserModel;
use think\model\concern\SoftDelete;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;

class RechargeOrderModel extends BaseModel
{
    use SoftDelete;

    protected $name = 'shop_recharge_order';

    /**
     * 关联用户
     * @return BelongsTo
     */
    public function user(): BelongsTo
    {
        return $this->belongsTo(UserModel::class, 'user_id', 'id');
    }

    /**
     * 关联第三方支付
     * @return HasOne
     * @noinspection PhpUnused
     */
    public function paymentTrade(): HasOne
    {
        return $this->hasOne(PaymentTradeModel::class, 'out_trade_no', 'out_trade_no');
    }
}